<script>
	<#if !formField.readonly?? || formField.readonly=="0">
    $(document).ready(function(){
        $(document.getElementById('uploadify${field.name?replace('.','_')}')).uploadify({
            'basepath'       : TDQS.CONTEXT_PATH,
            'queueID'        : "fieldMap['${field.name}'].fileQueue",
            'fileDesc' :  '<#if fileDesc??>${fileDesc}<#else>请选择文件</#if>',
            'sizeLimit' :<#if sizeLimit??>${sizeLimit}<#else>1024*1024*100</#if>,
            'fileExt' :'<#if fileExt??>${fileExt}<#else>*.doc;*.docx;*.xls;*.xlsx;*.pdf;*.zip;*.rar;*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.DWG;*.psd;*.dws;*.dxf;*.dwt;*.ppt;*.pptx;*.mmp;*.vsd;*.tif</#if>',
            'onSelect' : function(){
            	$('.button','.buttonBox').attr('disabled','disabled');
            },
            'onCancel' : function(){
            	$('.button','.buttonBox').attr('disabled',false);
            },
            'onError' : function(){
            	$('.button','.buttonBox').attr('disabled',false);
            },
            'onFileSizeError' : function(){
            	$('.button','.buttonBox').attr('disabled',false);
            },
            'onComplete' : function(event, ID, fileObj, response, data){
            	$('.button','.buttonBox').attr('disabled',false);
          		if(validator) {
					validator.element($(document.getElementById('file${field.name}')));			
				 }
            },
			'onCancelCompleted':function(event, ID, fileObj, data, remove, clearFast){
				if(validator) {
					validator.element($(document.getElementById('file${field.name}')));			
				}
			}
        });
    });
    </#if>
    function downloadAttachment${field.name?replace('.','_')}(attachmentId) {
    	var url = TDQS.CONTEXT_PATH+"/download/downLoadAttachment?attachmentId="+attachmentId+"&date="+new Date().toLocaleString();
    	var frame = document.createElement("iframe");
		frame.src = url;
		frame.style.display = "none";
		document.body.appendChild(frame);
    }
    function viewAttachment${field.name?replace('.','_')}(attachmentId) {
    	var url = TDQS.CONTEXT_PATH+"/download/viewAttachment?attachmentId="+attachmentId+"&instanceId=<#if businessInstanceField?? && businessInstanceField.instance?? && businessInstanceField.instance.id??>${businessInstanceField.instance.id}</#if>&date="+new Date().toLocaleString();
    	window.open(url);
    }
    function deleteAttachment${field.name?replace('.','_')}(index) {
    	jConfirm('确认要删除附件吗？', '确认对话框 ', function(r) {
			if(r){
                $(document.getElementById('fileInfo${field.name}'+index)).remove();
               	if(validator) {
					validator.element($(document.getElementById('file${field.name}')));
				}
            }else{
                return false;
            }
	  	});
    }
</script>
	 
<div id="${field.name}Form" style="width:650px">
<input type=hidden name="fieldMap['${field.name}'].id"  <#if businessInstanceField?? && businessInstanceField.id??>value="${businessInstanceField.id}"</#if>>
<input type=hidden name="fieldMap['${field.name}'].field.id"  value="${formField.field.id}">
<input type=hidden name="fieldMap['${field.name}'].entityId"  <#if businessInstanceField?? && businessInstanceField.entity??>value="${businessInstanceField.entity.id?default('')}"</#if>>

<#if (fileinfo_list?size?default(0) > 0)>
<table cellspacing="1" id="fileTable${field.name}" cellpadding="0" width="${formField.width?default('100%')}">
	<#assign index = 1>
	<tr class="listviewTR">
	<td width="85%" colSpan=6 style="line-height:20px">
	<#list fileinfo_list as fileinfo>
		<div id="fileInfo${field.name}${fileinfo.fileId}">
		<input type=hidden name="fieldMap['${field.name}'].oldFileQueue[${index}].fileId" value="${fileinfo.fileId}">
			<div style="position:relative;+position:static;_position:static;float:left;clear:left">
				<span class="fileName">
					<div style="width:650px">
						
						<div style="position:relative;_position:static;float:left;padding:2px;clear:left;width:20px">
							<img border="0" src="/PNPMS/script/plugins/Uploadify/global.jpg" class="statusimg">
						</div>
						<div style="position:relative;_position:static;float:left;width:500px">
							&nbsp;[${fileinfo.dateTime?string('yyyy-MM-dd')}]&nbsp;&nbsp;<a href="javascript:void(0);" onclick="downloadAttachment${field.name?replace('.','_')}('${fileinfo.fileId}');return false;"><#if fileinfo.realName?? && fileinfo.aliasName??><span title="${fileinfo.realName}">${fileinfo.aliasName}</span><#else>${fileinfo.realName}</#if></a>
							<#if fileinfo.ext?? && (fileinfo.ext=='doc' || fileinfo.ext=='DOC' || fileinfo.ext=='docx' || fileinfo.ext=='DOCX' || fileinfo.ext=='xls' || fileinfo.ext=='XLS' || fileinfo.ext=='xlsx' || fileinfo.ext=='XLSX' || fileinfo.ext=='pdf' || fileinfo.ext=='PDF' || fileinfo.ext=='jpg' || fileinfo.ext=='JPG' || fileinfo.ext=='jpeg' || fileinfo.ext=='JPEG' || fileinfo.ext=='bmp' || fileinfo.ext=='BMP' || fileinfo.ext=='png' || fileinfo.ext=='PNG' || fileinfo.ext=='gif' || fileinfo.ext=='GIF' || fileinfo.ext=='tif' || fileinfo.ext=='TIF' || fileinfo.ext=='ppt' || fileinfo.ext=='PPT' || fileinfo.ext=='pptx' || fileinfo.ext=='PPTX')>
							&nbsp;<a href="javascript:void(0);" onclick="viewAttachment${field.name?replace('.','_')}('${fileinfo.fileId}');return false;">预览</a>
							</#if>
						</div>
						<#if displayCompany>
						<div style="position:relative;_position:static;float:left;width:100px">
							&nbsp;&nbsp;<#if fileinfo.company??>${fileinfo.company.name?default('')}</#if>
						</div>
						</#if>
						<div style="position:relative;_position:static;float:left;width:20px" class="cancel">
							<#if !formField.readonly?? || formField.readonly=="0">
							<a href="javascript:void(0);" onclick="deleteAttachment${field.name?replace('.','_')}('${fileinfo.fileId}');return false;"><img border="0" src="/PNPMS/theme/default/images/main/delete.png"/></a>
							</#if>
						</div>	

					</div>
				</span>
			</div>
		</div>
	<#assign index = index+1>
	</#list>
	</td>
	</tr>
</table>
</#if>
	
<#if !formField.readonly?? || formField.readonly=="0">
<table cellspacing="1" cellpadding="0" width="100px" align="left">
	<tr class="listviewTR">
		<td>
			<div id="fieldMap['${field.name}'].fileQueue" style="text-align: left;">
				<#assign index=1>
				<#if businessInstanceField?? && businessInstanceField.fileQueue??>
					<#list  businessInstanceField.fileQueue as fileInfo>
						<#if fileInfo?? && fileInfo.realName??>
						<div id="uploadify${field.name}newfile${index}" class="uploadifyQueueItem completed" style="width:650px">
							<div style="width:520px;clear:left;float:left">
								<span class="fileName">
									<img class="statusimg" border="0" src="/PNPMS/script/plugins/Uploadify/global.jpg">
									&nbsp;${fileInfo.realName}(${fileInfo.fileSize})
								</span>
								<span class="percentage"></span>
							</div>
							<div class="cancel" style="padding:2px;float:left;width:20px">
								<a href="javascript:jQuery('#uploadify${field.name}').uploadifyCancel('newfile${index}')">
									<img border="0" src="/PNPMS/theme/default/images/main/delete.png">
								</a>
							</div>
							<input id="uploadify${field.name}newfile${index}hidvalue" type="hidden" value='{"aliasName":null,"company":null,"dateTime":null,"ext":null,"fileData":null,"fileId":null,"fileType":null,"length":0,"node":null,"fileSize":"${fileInfo.fileSize}","realName":"${fileInfo.realName}","realPath":"${fileInfo.realPath?replace('\\','/')}"}' name="fieldMap['${field.name}'].fileQueue">
						</div>
						<#assign index=index + 1>
						</#if>
					</#list>
				</#if>
			</div>
			<div style="clear:both">
			
 <#if templeteInstance?? && isDownLoadTemplete??>
<table cellspacing="0" cellpadding="0" style="border:0px;"><tr><td style="border:0px;">
				<input type="file" name="uploadify${field.name}" id="uploadify${field.name?replace('.','_')}" />
				</td><td style="border:0px;">
				<a href="#" class="button" tabindex="-1"><input type="button" onclick="downLoadFunction('${templeteInstance}','download/downLoad');return false;" value="下载模板"></a>
				</td></tr></table>
				
<#else>	
<input type="file" name="uploadify${field.name}" id="uploadify${field.name?replace('.','_')}" />
</#if>

			
				<input type=text <#if fieldrule??> datarule="${fieldrule.dataType}" datarulejson='${fieldrule.json}' </#if> name="file${field.name}" value="" id="file${field.name}" style="background-color:transparent; border:0px; width:0px;height:0px;" />
			</div>
		</td>
	</tr>
</table>
</#if>
</div>
		